package test.lucene.index;

import org.junit.Test;
import org.liuyuantao.lucene.index.IndexExample;

/**
 * Created by liuyuantao on 2017-7-19.
 */
public class IndexFile {
    public static final String INDEX_PATH = "src/main/resources/index/";
    public static final String DATA_PATH = "src/main/resources/data/";

    @Test
    public void makeIndex() {
        IndexExample indexer = null;
        int numIndexed = 0;
        long start = System.currentTimeMillis();
        try {
            indexer = new IndexExample(INDEX_PATH);
            // 创建索引
            numIndexed = indexer.makeIndex(DATA_PATH);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (indexer != null) {
                try {
                    indexer.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        long end = System.currentTimeMillis();
        System.out.println("索引:" + numIndexed + "个文件,花费了" + (end - start) + "毫秒");
    }
}
